package com.myk.game.sumeru.pages;

import android.content.Context;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.myk.game.sumeru.interfaces.IGame;
import com.myk.game.sumeru.databinding.PageHomeBinding;
import com.myk.game.sumeru.interfaces.IMainController;
import com.myk.game.lib.base.AbsBasePage;
import com.myk.game.sumeru.game.PersonalGame;
import com.myk.game.sumeru.game.RobotGame;

/**
 * 首页
 */
public class HomePage extends AbsBasePage<PageHomeBinding> {

    private final IMainController controller;

    public HomePage(@NonNull Context context) {
        super(context);
        this.controller = (IMainController) context;
        binding.tgebMusic.setChecked(controller.isMusicPlaying());
        binding.tgebMusic.setOnCheckedChangeListener((buttonView, isChecked) -> {
            if (isChecked) controller.openBgMusic();
            else controller.closeBgMusic();
        });
        binding.tsvModePersonal.setOnClickListener(v -> {
            GamePage gamePage = new GamePage(context);
            gamePage.chooseMode(PersonalGame.class);
            jumpPageTo(gamePage);
        });
        binding.tsvModeRobot.setOnClickListener(v -> {
            GamePage gamePage = new GamePage(context);
            gamePage.chooseMode(RobotGame.class);
            jumpPageTo(gamePage);
        });
        binding.tsvModeNetwork.setOnClickListener(v -> ToastUtils.showShort("敬请期待"));
        binding.tsvModeInternet.setOnClickListener(v -> ToastUtils.showShort("敬请期待"));
        binding.ivHelp.setOnClickListener(v -> jumpPageTo(HelpPage.class));
        binding.ivSetting.setOnClickListener(v -> jumpPageTo(SettingPage.class));
        binding.tvVersion.setText(AppUtils.getAppVersionName());
    }

}
